//
//  STLElement.m
//  iDent
//
//  Created by Marius Corega on 7/21/09.
//  Copyright 2009 Marius Corega. All rights reserved.
//

#import "STLElement.h"


@implementation STLElement

-(id) initWithData:(NSData*) data
{
	if(self = [super init])
	{
		[data getBytes:&_element range:NSMakeRange(0, 50)];
	}
	
	return self;
}

-(void) setElement:(TSTLElement) e
{
	_element = e;
}
-(TSTLElement) element
{
	return _element;
}

-(NSDictionary *) dictValue
{
	NSMutableDictionary *dict = [NSMutableDictionary dictionary] ;
	
/*
	[dict setValue:[NSNumber numberWithFloat:_element.v1.x] forKey:@"v1x"];
	[dict setValue:[NSNumber numberWithFloat:_element.v2.x] forKey:@"v2x"];
	[dict setValue:[NSNumber numberWithFloat:_element.v3.x] forKey:@"v3x"];
	[dict setValue:[NSNumber numberWithFloat:_element.v1.y] forKey:@"v1y"];
	[dict setValue:[NSNumber numberWithFloat:_element.v2.y] forKey:@"v2y"];
	[dict setValue:[NSNumber numberWithFloat:_element.v3.y] forKey:@"v3y"];
	[dict setValue:[NSNumber numberWithFloat:_element.v1.z] forKey:@"v1z"];
	[dict setValue:[NSNumber numberWithFloat:_element.v2.z] forKey:@"v2z"];
	[dict setValue:[NSNumber numberWithFloat:_element.v3.z] forKey:@"v3z"];

	[dict setValue:[NSNumber numberWithFloat:_element.normal.x] forKey:@"nx"];
	[dict setValue:[NSNumber numberWithFloat:_element.normal.y] forKey:@"ny"];
	[dict setValue:[NSNumber numberWithFloat:_element.normal.z] forKey:@"nz"];
*/
	
	NSMutableData *data = [NSMutableData dataWithBytes:&_element length:sizeof(_element)] ;
	
	[dict setValue:data forKey:@"3DElement"];
	
	return dict;
}

-(NSData *) dataValue
{
	NSMutableData *data = [NSMutableData dataWithBytes:&_element length:sizeof(_element)] ;

	return data;
}

@end
